home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / cstdio.arc / INCLUDE.ARC / STDIO.H < prev    next >
C/C++ Source or Header  |  1984-07-31  |  1KB  |  60 lines

  1. /*    stdio.h - standard I/O definitions.
  2.     K & R page 165.
  3.     Entered - G. R. Mansfield.  84/06/05.
  4.     Ver 1.4-4731.
  5. */
  6.  
  7. #ifndef _stdio
  8. #define _stdio
  9.  
  10. #define BUFSIZE 512
  11. #define _NFILE 12
  12.  
  13. typedef struct _iobuf {
  14.     char *_ptr;    /* next character position */
  15.     int _cnt;    /* number of characters left */
  16.     char *_base; /* location of buffer */
  17.     int    _flag;    /* mode of file access */
  18.     int _fd;    /* file descriptor */
  19. } FILE;
  20.  
  21. #ifndef IO2INIT
  22. extern FILE _iob[_NFILE];
  23. #endif
  24.  
  25. #define stdin (&_iob[0])
  26. #define stdout (&_iob[1])
  27. #define stderr (&_iob[2])
  28. #define stdbfr (&_iob[3])
  29.  
  30. #define _READ 0x01 /* file open for reading */
  31. #define _WRITE 0x02 /* file open for writing */
  32. #define _UNBUF 0x04 /* file is unbuffered */
  33. #define _EOF 0x10 /* EOF has occurred on this file */
  34. #define _ERR 0x20 /* error has occurred on this file */
  35. #ifndef NULL
  36. #define NULL (0)
  37. #endif
  38. #define EOF (-1)
  39. #ifndef ERR
  40. #define ERR (-1)
  41. #endif
  42. #ifndef LERR
  43. #define LERR (-1L)
  44. #endif
  45.  
  46. #define getc(p) (--(p)->_cnt >= 0 \
  47.             ? (*(p)->_ptr++) : _fillbuf(p))
  48. #define getchar() getc(stdin)
  49.  
  50. #define putc(c,p) (--(p)->_cnt >= 0 \
  51.             ? ((int)(*(p)->_ptr++ = (c))) : _mtybuf((c),p))
  52. #define putchar(c) putc(c, stdout)
  53.  
  54. #define clearerr(fp) ((fp)->_flag & ~_ERR)
  55. #define feof(fp) ((fp)->_flag & _EOF)
  56. #define ferror(fp) ((fp)->_flag & _ERR)
  57. #define fileno(fp) ((fp)->_fd)
  58.  
  59. #endif
  60.